package com.captain.leetcode.二维数组;

/**
 * Des:
 *
 * @author XL
 * @Date 2021/8/6 17:09
 */
public class 二维数组的上右下左 {


    public static void main(String[] args) {
        int[][] arr = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        new 二维数组的上右下左().around(arr);
    }

    /**
     * des:
     *
     * @param arr 原二维数组
     * @return {@link }
     * @author captain
     * @date 2021/8/9 8:45
     */
    public void around(int[][] arr) {
        int m = arr.length;
        int n = arr[0].length;
        int[][] around = new int[][]{{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
        /**
         * 1 2 3
         * 4 5 6     1 , 1  上 0,1  右:1,2 下 2,1 左: 1,0
         * 7 8 9
         */
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                for (int[] ints : around) {
                    int x = i + ints[0];
                    int y = j + ints[1];
                }
            }
        }
    }
}
